package sengine;

/**
 * Kinematics for a generic rectangular 2D object.  All units are in pixels and seconds.
 * @author twoodf5611
 */
public class Object2D {
    public float height, width, x, y;
    private float vx, vy, ax, ay;
    private float r, vr, ar;
    private PhysicsType physType;
    private float mass;

    public Object2D(float x, float y, float width, float height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public float getHeight() {
        return height;
    }

    public float getWidth() {
        return width;
    }

    public float getX() {
        return x;
    }

    public float getY() {
        return y;
    }

    public void setX(float x) {
        this.x = x;
    }

    public void setY(float y) {
        this.y = y;
    }

    public float getVx() {
        return vx;
    }

    public void setVx(float vx) {
        this.vx = vx;
    }

    public float getVy() {
        return vy;
    }

    public void setVy(float vy) {
        this.vy = vy;
    }

    public float getAx() {
        return ax;
    }

    public void setAx(float ax) {
        this.ax = ax;
    }

    public float getAy() {
        return ay;
    }

    public void setAy(float ay) {
        this.ay = ay;
    }

    public float getR() {
        return r;
    }

    public void setR(float r) {
        this.r = r;
    }

    public float getVr() {
        return vr;
    }

    public void setVr(float vr) {
        this.vr = vr;
    }

    public float getAr() {
        return ar;
    }

    public void setAr(float ar) {
        this.ar = ar;
    }
    
    public void update(long millis) {
    }
    
    /**
     * Called by the physics engine
     * @param millis 
     */
    protected void kinematicsUpdate(long millis) {
        float tpf = millis/1000.0f;
        vx += tpf * ax;
        vy += tpf * ay;
        vr += tpf * ar;
        x += tpf * vx;
        y += tpf * vy;
        r += tpf * vr;
    }

    public PhysicsType getPhysType() {
        return physType;
    }

    public void setPhysType(PhysicsType physType) {
        this.physType = physType;
    }

    public float getMass() {
        return mass;
    }

    public void setMass(float mass) {
        this.mass = mass;
    }
    
    public enum PhysicsType {
        FIXED, MOVABLE, FLOATING, BULLET
    }
    
    @Override
    public String toString() {
        return this.getClass().getSimpleName()+"[x="+x+",y="+y+"]";
    }
}
